Hi all,
I am having a problem with some netcdf .grd files that I created with MATLAB using Kelsey Jordahl’s grdwrite2 script. I’ve been using Kelsey’s MATLAB-GMT interface scripts for literally decades, and they’ve always worked fine. But now GMT5 won’t recognize them as legit netcdf files. Note the following output from gmt5 grdinfo:
MP-McGovern-14:LPSC_frantic mcgovern$ gmt5 grdinfo svv_out.grd
grdinfo (api_import_grid): NetCDF: Attempting netcdf-4 operation on netcdf-3 file [svv_out.grd]
[Session gmt5 (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session gmt5 (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session gmt5 (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
This has never happened before, and only started happening after I implemented the joint install of GMT 5 and GMT6 from MacPorts. That changed the “prefix” for using GMT 5 from simply “gmt” to “gmt5”, but apparently some actual functionality changed as well.
I will note that GMT 6 can read the files:
MP-McGovern-14:LPSC_frantic mcgovern$ gmt6 grdinfo svv_out.grd
grdinfo [WARNING]: The y-coordinates and range attribute are in conflict; must rely on coordinates only
svv_out.grd: Title: svv_out.grd
svv_out.grd: Command: File written by MATLAB function grdwrite2.m
svv_out.grd: Remark: Created 29-Jul-2020 14:16:06
svv_out.grd: Gridline node registration used [Cartesian grid]
svv_out.grd: Grid file format: nd = GMT netCDF format (64-bit float), CF-1.7
svv_out.grd: x_min: 0 x_max: 1866 x_inc: 2 name: x n_columns: 934
svv_out.grd: y_min: -50 y_max: -0 y_inc: 1 name: y n_rows: 51
svv_out.grd: z_min: -30.5628037562 z_max: 0.00118786475074 name: z
svv_out.grd: scale_factor: 1 add_offset: 0
svv_out.grd: format: classic
But I’m not out of the woods yet, because using such files in programs like grdimage gives me problems I’ve never seen before:
grdimage [WARNING]: The y-coordinates and range attribute are in conflict; must rely on coordinates only
…and I end up not getting useful output from it; the .ps file won’t display on my Mac because Preview thinks it’s not a proper .ps file.
So, I’m wondering if any of you can give me some insight into what’s going on here. I will note that I’ve already seen responses of “Just use Python widget XLBLORB (or whatever) to convert to netcdf4”, and that’s a good last resort, but I’ve got literally hundreds of such files that I need to use, and laboriously finding and converting them all individually is something I am hoping (and reasonably, I think, expecting) to avoid. In other words, I’m hoping that there’s a solution that simply restores GMT 5’s previous ability to handle these files.
Thanks in advance for your help,Pat